<?php
/**
 * Smart Library - Smart Framework
 * http://smart-framework.highet.eu
 *
 * @category   SmartL
 * @package    SmartL_DatabaseManager
 * @copyright  Copyright (c) 2005-2008 Smart Framework team - Stepan Sindelar, Vojtech Vit
 * @license    http://www.opensource.org/licenses/bsd-license.php	New BSD License
 */

/**
 * Interface for database manager.
 * Abstraction of ORM managers and also other (e.g. Zend_Db)
 * 
 * Managers should implement Singleton pattern with one static method getInstance.
 *
 * @package SmartL_DatabaseManager
 */
interface SmartL_DatabaseManager_Interface {
	/**
	 * Opens connection.
	 *
	 * @param string name All managers will be saved in array indexed by connection name. In fact
	 * lot of them are singletons, so they need some string for name of new connection.
	 * 
	 * @param array $options Array with options given in config. 
	 * Usually the main option is connection string which is usually given under index 'connectionString'.
	 * But some adapters requires more options and these can be also given in their config connection-tag.
	 * E.g. <add id="myConnection" connectionString="blah[at]localhost" persistent="true"/>
	 * 
	 * @exception SmartL_DatabaseManager_Exception When connection failed, or wrong options are given.
	 */
	public function openDbConnection($name, $options);
	
	/**
	 * Sets current connection for this manager.
	 *
	 * @param string $name Name of current connection.
	 */
	public function setCurrentConnection($name);
	
	/**
	 * @return string Name of current connection.
	 */
	public function getCurrentConnectionName();
	
	/**
	 * Rteurns connection object with given name.
	 *
	 * @param string $name
	 */
	public function getConnection($name);
	
	/**
	 * @return string Name of ORM or library which this manager represents (e.g. Doctrine).
	 */
	public function getLibraryName();
}